from django.conf.urls.defaults import *
from django.views.generic import ListView, CreateView, DetailView
from machete.models import Page
from machete.forms import *
from machete.detailviews import *
from machete.updateviews import *

urlpatterns = patterns('machete.views',
    (r'^$', 'list_greetings'),
    (r'^sign$', 'create_greeting'),
    
    # ============= Page ================
    (r'^page/$', 'view_page_last'),
    (r'^page/(?P<entity_id>\d+)/$', 'view_page'),
)
 
urlpatterns += patterns('machete.adminviews',
                          
    # ============= Admin Page ================
    (r'^admin_home$', 'admin_home'),
    (r'^admin_createpage$',
        CreateView.as_view(
            form_class = AdminCreatePageForm,
            template_name = 'machete/admin/createpage.html',
            success_url = '/admin/admin_listpage')),
    (r'^admin_detailpage/(?P<pk>\d+)/$',
        PageDetailView.as_view()),
    (r'^admin_updatepage/(?P<pk>\d+)/$',
        PageUpdateView.as_view()),
    (r'^admin_deletepage/(?P<entity_id>\d+)/$','admin_deletepage'),
    (r'^admin_listpage$',
        ListView.as_view(
             queryset=Page.objects.all().order_by('-date'),
             context_object_name='page_list',
             template_name='machete/admin/listpage.html')),
                       
    # ============= Admin category ================
    (r'^admin_createcategory$',
        CreateView.as_view(
            form_class = AdminCreateCategoryForm,
            template_name = 'machete/admin/createcategory.html',
            success_url = '/admin/admin_listcategory')),
    (r'^admin_detailcategory/(?P<pk>\d+)/$',
        CategoryDetailView.as_view()),
    (r'^admin_updatecategory/(?P<pk>\d+)/$',
        CategoryUpdateView.as_view()),
    (r'^admin_deletecategory/(?P<entity_id>\d+)/$','admin_deletecategory'),
    (r'^admin_listcategory$',
        ListView.as_view(
             queryset=Category.objects.all(),
             context_object_name='category_list',
             template_name='machete/admin/listcategory.html')),
                       
                       
    # ============= Admin Slideshow ================
    (r'^admin_createslideshow$',
        CreateView.as_view(
            form_class = AdminCreateSlideshowForm,
            template_name = 'machete/admin/createslideshow.html',
            success_url = '/admin/admin_listslideshow')),
    (r'^admin_detailslideshow/(?P<pk>\d+)/$',
        SlideshowDetailView.as_view()),
    (r'^admin_updateslideshow/(?P<pk>\d+)/$',
        SlideshowUpdateView.as_view()),
    (r'^admin_deleteslideshow/(?P<entity_id>\d+)/$','admin_deleteslideshow'),
    (r'^admin_listslideshow$',
        ListView.as_view(
             queryset=Slideshow.objects.all(),
             context_object_name='slideshow_list',
             template_name='machete/admin/listslideshow.html')),
                       
                       
    # ============= Admin Photo ================
    (r'^admin_createphoto$',
        CreateView.as_view(
            form_class = AdminCreatePhotoForm,
            template_name = 'machete/admin/createphoto.html',
            success_url = '/admin/admin_listphoto')),
    (r'^admin_detailphoto/(?P<pk>\d+)/$',
        PhotoDetailView.as_view()),
    (r'^admin_updatephoto/(?P<pk>\d+)/$',
        PhotoUpdateView.as_view()),
    (r'^admin_deletephoto/(?P<entity_id>\d+)/$','admin_deletephoto'),
    (r'^admin_listphoto$',
        ListView.as_view(
             queryset=Photo.objects.all(),
             context_object_name='photo_list',
             template_name='machete/admin/listphoto.html')),
                       
    # ============= Admin Link SlideshowPage ================
    (r'^admin_createlink_slideshowpage$',
        CreateView.as_view(
            form_class = AdminCreateLinkSlideshowPageForm,
            template_name = 'machete/admin/link/createslideshowpage.html',
            success_url = '/admin/admin_listlink_slideshowpage')),
    (r'^admin_detaillink_slideshowpage/(?P<pk>\d+)/$',
        LinkSlideshowPageDetailView.as_view()),
    (r'^admin_updatelink_slideshowpage/(?P<slideshow_id>\d+)/$', 'admin_updatelink_slideshowpage'),
    (r'^admin_updatelink_slideshowpageByPage/(?P<page_id>\d+)/$', 'admin_updatelink_slideshowpageByPage'),
    (r'^admin_deletelink_slideshowpage/(?P<entity_id>\d+)/$','admin_deletelink_slideshowpage'),
    (r'^admin_listlink_slideshowpage$',
        ListView.as_view(
             queryset=LinkSlideshowPage.objects.all(),
             context_object_name='entity_list',
             template_name='machete/admin/link/listslideshowpage.html')),
                   
                   
    # ============= Admin Link PhotoSlideshow ================
    (r'^admin_createlink_photoslideshow$',
        CreateView.as_view(
            form_class = AdminCreateLinkPhotoSlideshowForm,
            template_name = 'machete/admin/link/createphotoslideshow.html',
            success_url = '/admin/admin_listlink_photoslideshow')),
    (r'^admin_detaillink_photoslideshow/(?P<pk>\d+)/$',
        LinkPhotoSlideshowDetailView.as_view()),
    (r'^admin_updatelink_photoslideshow/(?P<photo_id>\d+)/$','admin_updatelink_photoslideshow'),
    (r'^admin_updatelink_photoslideshowBySlideshow/(?P<slideshow_id>\d+)/$','admin_updatelink_photoslideshowBySlideshow'),
    (r'^admin_deletelink_photoslideshow/(?P<entity_id>\d+)/$','admin_deletelink_photoslideshow'),
    (r'^admin_listlink_photoslideshow$',
        ListView.as_view(
             queryset=LinkPhotoSlideshow.objects.all(),
             context_object_name='entity_list',
             template_name='machete/admin/link/listphotoslideshow.html')),
)
